<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
    <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
    <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
    <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>

<body>

    <div id="example"></div>
    <script type="text/babel">
        class Demo extends React.Component {
            state = {isHot: true};

            showInfo = () => {
                alert(this.input1.value)
            }

            changeWeather  = () => {
                const {isHot} = this.state
                this.setState({
                    isHot: !isHot
                })
            }

            render() {
                const {isHot} = this.state
                return (
                    <div>
                        <h2>今天天气很{isHot ? '炎热' : '凉爽'}</h2>
                        <input ref={(a) => {this.input1  = a ; console.log('1', a)}} type="text"/>
                        <button onClick={this.showInfo}>点我提示输入的数据</button>
                        <button onClick={this.changeWeather}>点我改变天气</button>
                    </div>
                );
            }
        }

        ReactDOM.render(
            <Demo />,
            document.getElementById('example')
        );
    </script>

</body>

</html>